/**
 * 
 */
package com.gauss.render;

import java.io.File;

import com.gauss.speex.encode.SpeexDecoder;

/**
 * @author Gauss
 * 
 */
public class SpeexPlayer implements Runnable
{
	private String fileName = null;
	private SpeexDecoder speexdec = null;

	public SpeexPlayer(String fileName)
	{

		this.fileName = fileName;
		System.out.println(this.fileName);
		try
		{
			speexdec = new SpeexDecoder(new File(this.fileName));
		}
		catch (Exception e)
		{
			e.printStackTrace();
		}
	}

	public void stopPlay()
	{

		if (speexdec != null)
		{
			speexdec.Stop();
		}
	}

	public void startPlay()
	{

		Thread th = new Thread(this);
		th.start();
	}

	@Override
	public void run()
	{
		try
		{
			if (speexdec != null)
				speexdec.decode();

		}
		catch (Exception t)
		{
			t.printStackTrace();
		}

	};
}
